from django.db import models


# Create your models here.
class User(models.Model):
    user = models.CharField(unique=True, max_length=32, verbose_name="用户名")
    password = models.CharField(max_length=48, verbose_name="密码")
    nickname = models.CharField(max_length=32, verbose_name="昵称")
    email = models.EmailField(verbose_name="邮箱")

    def __str__(self):
        return self.user


class Resource(models.Model):
    date = models.DateField(verbose_name="发表日期")
    user = models.ForeignKey(User,verbose_name="贡献者",on_delete=None)
    title = models.CharField(unique=True, max_length=32, verbose_name="资源名称")
    url = models.URLField(unique=True, max_length=70, verbose_name="下载地址")
    tag_choices = [
        (1, "Python"),
        (2, "Linux"),
        (3, "Java"),
        (4, "Mysql"),
        (5, "OpenStack"),
        (6, "JavaScript"),
        (7, "Oracle"),
        (8, "KVM"),
        (9, "Network"),
        (10, "Docker"),
    ]
    tag = models.IntegerField(choices=tag_choices,default=1, verbose_name="标签")
    # up = models.IntegerField(verbose_name="赞",default=1)
    # down = models.IntegerField(verbose_name="踩",default=2)
    remark=models.CharField(max_length=64, verbose_name="备注",null=True)


class UserToken(models.Model):
    user = models.OneToOneField(to="User",on_delete=None)
    token = models.CharField(max_length=64)

